<?php

namespace app\admin\validate;

use think\Validate;

class Inventory extends Validate
{
    protected $rule = [
        'productid' => ['require', 'integer'],
        'sku'       => ['require', 'max' => 50],
        'wid'       => ['require'],
        'check_qty'       => ['require'],
        'remark'       => ['require'],
        'qty'       => ['require', 'integer', 'egt' => 0],
        'pending_qty' => ['require', 'integer', 'egt' => 0],
        'min_num'   => ['require', 'integer', 'egt' => 1],
        'estimated_ship_date' => ['integer', 'egt' => 0],
        'cost'      => ['require', 'decimal', 'egt' => 0],
        'sales_rate' => ['require', 'decimal', 'egt' => 0],
        'unit_price' => ['decimal'],
        'sales_price' => ['decimal'],
        'freight_price' => ['decimal'],
        'is_advance' => ['require', 'in' => ['0', '1']],
        'advance_ratio' => ['decimal', 'between' => [0, 1]],
        'advance_amount' => ['decimal'],
        'remark'    => ['max' => 1000],
        'creator'   => ['require', 'integer'],
        'create_time' => ['date'],
        'update_time' => ['date'],
        'updater'   => ['integer'],
        'last_audit_date' => ['date'],
        'is_del'    => ['require', 'in' => [0]],
        'is_futures' => ['require', 'in' => [0, 1]],
        'is_sale' => ['require', 'in' => [0, 1]],
        'allow_zero_stock_sale' => ['require', 'in' => [0, 1]],
        'product' => ['string'],
        'brand' => ['integer'],
        'arrival_date' => ['string'],
        'id' => ['require'],
        'currentWId' => ['require'],
        'ccname_ids' => ['require'],
        'productInfo' => ['require'],
        'company_id' => ['require'],
        'action_type' => ['require'],
        'available_qty' => ['in:asc,desc'],
        'lock_qty' => ['in:asc,desc'],
        'actual_available_qty' => ['in:asc,desc'],
    ];

    protected $scene = [
        'search' => ['sku' => 'max:255', 'cname' => 'max:255', 'sort_field', 'sort_order'],
        'delete' => ['ids' => 'require|array|checkIds'],
        'sale' => ['ids' => 'require|array|checkIds', 'is_sale'],
        'allowZero' => ['ids' => 'require|array|checkIds', 'allow_zero_stock_sale'],
        'show' => ['id' => 'require'],
        'merge' => ['product', 'brand', 'arrival_date'],
        'getOrderByInventory' => ['currentWId', 'id'],
        'transEnum' => ['id'],
        'fixSavePrice' => ['id'],
        'submitCheckApi' => ['id','check_qty','remark','action_type'],
        'transSaveByOrder' => ['list'],
        'transSaveByWholesal' => ['id'],
        'baskets' => ['ccname_ids'],
        'transfer' => ['company_id','productInfo','wid']
    ];
}
